package com.tarena.lbs.basic.web.rpc;

import com.tarena.lbs.basic.api.UserGroupApi;
import com.tarena.lbs.basic.web.service.IBusinessService;
import com.tarena.lbs.basic.web.service.IUserGroupService;
import com.tarena.lbs.basic.web.service.IUserService;
import com.tarena.lbs.common.basic.converter.UserConverter;
import com.tarena.lbs.pojo.basic.bo.UserBO;
import com.tarena.lbs.pojo.basic.vo.BusinessVO;
import com.tarena.lbs.pojo.basic.vo.UserVO;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class UserGroupApiImpl implements UserGroupApi {

    @Resource
    private IUserService userService;

    @Resource
    private UserConverter userConverter;

    @Resource
    private IUserGroupService userGroupService;

    @Resource
    private IBusinessService businessService;

    @Override
    public boolean verificationByUserGroupIDS(List<Integer> ids) {

        return  userGroupService.verificationByUserGroupIDS(ids);

    }

    @Override
    public boolean isUserInTargetGroup(int userId,String userGroupIds) {

        return  userGroupService.isUserInTargetGroup(userId,userGroupIds);
    }

    @Override public UserVO getUser(Integer id) {
        UserBO userBO = userService.getDetail(id);
        log.info("当前userId:{},查询到的userBO:{}",id,userBO);
        return userConverter.bo2vo(userBO);
    }

    @Override
    public BusinessVO businessDetail(Integer id) {
        return businessService.businessDetail(id);
    }

    @Override
    public BusinessVO getBusinessInfoByAdminId(Integer adminId) {
        return businessService.getBusinessInfoByAdminId(adminId);
    }

    @Override public List<Integer> getUserByTargetGroup(List<Integer> userGroupIds) {
        return userGroupService.getUserByTargetGroup(userGroupIds);
    }
}
